package com.efruit.productInfoMag;

import java.util.List;


public class ProductInfoMagProxy {
	
	private IProductInfoFetcher productInfoFetcher= null;
	
	public IProductInfo add(String productName, String url, float price,
			int count) {
		testProductInfoFetcher();
		System.out.println("ProductInfoMagProxy.add()");
		return productInfoFetcher.add(productName, url, price, count);
	
	}

	public boolean remove(int id) {
		testProductInfoFetcher();
		productInfoFetcher.remove(id);
		return true;
	}

	public IProductInfo update(int id, String productName, String url,
			float price, int count) {
		testProductInfoFetcher();
		
		return productInfoFetcher.update(id, productName, url, price, count);
	}

	public List<IProductInfo> getAllProductInfo() {
		testProductInfoFetcher();
		return productInfoFetcher.getAllProductInfo();
	}
	
	private void testProductInfoFetcher(){
		if( productInfoFetcher == null ){
			productInfoFetcher = ProductInfoMagFactory.getDAOFactory().getProductInfoFetcher();
		}
	}

	public IProductInfo getProductInfo(int id) {
		testProductInfoFetcher();
		return productInfoFetcher.getProductInfo(id);
	}
}
